package axonactive.vision.traning.test.selenium.bean;

import java.io.FileInputStream;
import java.util.Properties;

import ch.ivyteam.ivy.environment.Ivy;

public class Configuration {
	private static Configuration instance = null;
	Properties prop = null;
	String configPath = System.getProperty("user.dir")
			+ "\\environment\\config.properties";

	// browser
	public static final String BROWSE_MODE_IE = "IE";
	public static final String BROWSE_MODE_FE = "FF";
	public static final String BROWSE_MODE_CHR = "CHR";
	public static final String BROWSE_MODE_SA = "SA";

	// extra infor
	public static final String BASE_URL = "baseUrl";
	public static final String AUTO_SWTCH_BROWSER = "autoSwichBrowser";
	public static final String BROWSER_MODE = "browserMode";
	public static final String TEST_DIR = "testDir";
	public static final String IMPLICIWAIT = "implicitWait";
	public static final String WEB_ELEMENT_PREFIX = "WebElementPrefix";

	// sauce connect
	public static final String IS_SAUCE_CONNECT = "isSauceConnect";
	public static final String URL_SAUCE_CONNECT = "urlSauceConnect";
	public static final String URL = "url";
	public static final String URL_LOCAL_HUB = "urlLocalHub";
	public static final String URL_SAUCE_CONNECT_LINUX = "urlSauceConnectLinux";
	
	// job information
	public static final String JOB_NAME = "job_name";
	public static final String JOB_BUILD = "job_build";
	public static final String JOB_TAGS = "job_tags";

	// login
	public static final String USER_NAME = "userName";
	public static final String ACCESS_KEY = "accessKey";
	public static final String PARENT_ACCOUNT = "parentAccount";
	
	// web ie driver
	public static final String IS_USE_WEB_DRIVER = "isUseWebDriverIE";
	public static final String WEB_DRIVER_IE = "webDriverIE";
	public static final String WEB_DRIVER_CHROME = "webDriverChrome";
	
	// unit test
	public static final String XML_SETTING_FILE_PATH = "xmlConfigPath.exceptionHandling";
	
	public static Configuration getInstance() {
		try {
			if (instance == null) {
				instance = new Configuration();
				instance.prop = new Properties();
				instance.prop.load(new FileInputStream(instance.configPath));
			}
		} catch (Exception e) {
			Ivy.log().error(e.getMessage());
		}
		return instance;
	}

	public String getProperty(String property) {
		return prop.getProperty(property);
	}

	public void setProperty(String property, String value) {
		prop.setProperty(property, value);
	}

}
